package com.zzyy.study.controller;

import com.zzyy.study.common.Result;
import com.zzyy.study.common.ResultUtils;
import com.zzyy.study.dto.TransferRequest;
import com.zzyy.study.idempotent.IdempotentCallRequest;
import com.zzyy.study.idempotent.IdempotentCallResponse;
import com.zzyy.study.service.AccountTransferService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class AccountController {
    @Resource
    private AccountTransferService accountTransferService;

    @PostMapping("/account/transfer")
    public Result<IdempotentCallResponse<Void>> transfer(@RequestBody IdempotentCallRequest<TransferRequest> request) {
        IdempotentCallResponse<Void> transferResponse = this.accountTransferService.call(request);
        return ResultUtils.success(transferResponse);
    }
}
